//
//  ZCUserAccount.swift
//  weibo
//
//  Created by 张城 on 16/7/22.
//  Copyright © 2016年 张城. All rights reserved.
//

import UIKit

class ZCUserAccount: NSObject , NSCoding {
    
    var access_token: String?
    var expires_in : Double = 0{
        didSet{
            expires_date = NSDate(timeIntervalSinceNow: expires_in)
            
        }
    }
    var uid: String?
    var avatar_large: String?
    var screen_name: String?
    var expires_date: NSDate?
    
    
    
   
    init(dic:[ String: AnyObject]) {
        super.init()
        setValuesForKeysWithDictionary(dic)
    }

    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
    }
    
    override var description: String {
        let keys = ["access_token","expires_in","uid","screen_name","avatar_large"]
        return dictionaryWithValuesForKeys(keys).description
    }
    
    func encodeWithCoder(aCoder: NSCoder) {
        aCoder.encodeObject(access_token, forKey: "access_token")
        aCoder.encodeObject(expires_date, forKey: "expires_date")
        aCoder.encodeObject(uid, forKey: "uid")
        aCoder.encodeObject(screen_name, forKey: "screen_name")
        aCoder.encodeObject(avatar_large, forKey: "avatar_large")
    }
    
    required init?(coder aDecoder: NSCoder) {
        access_token = aDecoder.decodeObjectForKey("access_token") as? String
        expires_date = aDecoder.decodeObjectForKey("expires_date") as? NSDate
        uid = aDecoder.decodeObjectForKey("uid") as? String
        screen_name = aDecoder.decodeObjectForKey("screen_name") as? String
        avatar_large = aDecoder.decodeObjectForKey("avatar_large") as? String
       
    }
   
}

















